package edu.pku.sei.transformation.semantics.match;

import choco.kernel.solver.constraints.integer.extension.TuplesTest;
import edu.pku.sei.mdabase.core.ICSPModelManager;
import edu.pku.sei.mdabase.infrastructure.model.MClass;
import edu.pku.sei.mdabase.infrastructure.model.MReference;

public class ReferenceTest extends TuplesTest {
	

	private ICSPModelManager manager;
	
	public ReferenceTest(ICSPModelManager manager){
		this.manager = manager;
	}
	

	@Override
	public boolean checkTuple(int[] args) {
		MReference ref = (MReference)manager.getModelObjectByID(args[0]);
		MClass src = (MClass)manager.getModelObjectByID(args[1]);
		MClass tar = (MClass)manager.getModelObjectByID(args[2]);
		if (ref == null)
			return false;
		if(ref.getSource()==src&&ref.getTarget()==tar)
			return true;
		return false;
	}

}
